﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections;

namespace GUI_CLock
{
    public class Binary_Digit
    {
        //Binary_Digit class for GUI_Clock  J. Brooks  5/10/11
        //Draws a binary digit on a canvas with dimension parameters
        //Display sets bits red and white depending on input number


        Ellipse[] ellipses = new Ellipse[7];

        //neumonic for ellipses L2 = 2nd from top left  R4 = Bottom right
        enum ellipseindexes : int { L2, L3, L4, R1, R2, R3, R4 };

        int Xpos, Ypos, Xsize, Ysize, Strokethickness, i;

        public Binary_Digit(int xpos, int ypos, int xsize, int ysize, int strokethickness)
        {

            //Constructor creates the ellipses for a binary digit display

            //Save the inputs
            this.Xpos = xpos;
            this.Ypos = ypos;
            this.Xsize = xsize;
            this.Ysize = ysize;
            this.Strokethickness = strokethickness;

            //Set up the Binary_Digit ellipse positions
            for (i = 0; i < 7; i++)
            {
                //Common for all ellipses
                ellipses[i] = new Ellipse();
                ellipses[i].Width = this.Xsize;
                ellipses[i].Height = this.Ysize;
                ellipses[i].Stroke = System.Windows.Media.Brushes.Black;  //Runtime change color?
                ellipses[i].HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                ellipses[i].VerticalAlignment = VerticalAlignment.Center;
                ellipses[i].StrokeThickness = this.Strokethickness;
                ellipses[i].Fill = System.Windows.Media.Brushes.Red;
 
                //Specific ellipse positions
                switch (i)
                {
                    case 0:  //2nd Left
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos);
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 1 * (this.Ysize + this.Strokethickness));
                        break;

                    case 1:  //third left
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos);
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 2 * (this.Ysize + this.Strokethickness));
                        break;

                    case 2:  //bottom left
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos);
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 3 * (this.Ysize + this.Strokethickness));
                        break;

                    case 3:  //Top right
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos + 1 * (this.Xsize + this.Strokethickness));
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 0 * (this.Ysize + this.Strokethickness));
                        break;

                    case 4:  //second right 
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos + 1 * (this.Xsize + this.Strokethickness));
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 1 * (this.Ysize + this.Strokethickness));
                        break;

                    case 5:  //third right
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos + 1 * (this.Xsize + this.Strokethickness));
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 2 * (this.Ysize + this.Strokethickness));
                        break;

                    case 6:  //Bottom right
                        ellipses[i].SetValue(Canvas.LeftProperty, (double)this.Xpos + 1 * (this.Xsize + this.Strokethickness));
                        ellipses[i].SetValue(Canvas.TopProperty, (double)this.Ypos + 3 * (this.Ysize + this.Strokethickness));
                        break;

                    default:
                        break;


                }
            }
        }

        public void blankDigit(Canvas canvas)
        {
            //Turn off the digit ellipses one at a time
            //Bit 6, L2 is not shown, because it is not needed for counts < 64
            for (i = 1; i < 7; i++)
            {
                //Remove first then add to avoid system error
                canvas.Children.Remove(ellipses[i]);
                canvas.Children.Add(ellipses[i]);
                ellipses[i].Fill = System.Windows.Media.Brushes.White;
            }
        }
        public void displayDigit(int number, Canvas canvas)
        {
            //Turn it off first
            blankDigit(canvas);

            switch (number)
            {
                case 0:

                    break;

                case 1:

                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 2:

                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 3:

                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 4:

                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 5:

                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 6:

                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 7:

                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 8:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 9:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 10:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 11:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 12:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 13:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 14:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 15:

                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 16:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 17:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 18:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 19:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 20:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 21:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;


                case 22:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 23:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;


                case 24:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    break;


                case 25:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 26:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 27:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;


                case 28:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 29:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 30:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 31:

                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 32:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 33:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 34:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 35:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 36:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 37:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 38:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 39:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 40:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 41:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 42:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 43:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 44:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 45:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 46:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 47:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 48:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 49:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 50:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 51:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 52:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 53:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 54:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 55:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 56:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 57:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 58:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    break;

                case 59:

                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;

                
                
                
                
                //Show  all red for error if number>59 | number<0
                default:
                    ellipses[(int)ellipseindexes.L3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.L4].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R1].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R2].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R3].Fill = System.Windows.Media.Brushes.Red;
                    ellipses[(int)ellipseindexes.R4].Fill = System.Windows.Media.Brushes.Red;
                    break;
            }
        }
    }
}
